home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat3 / Tcl / tildesubst.z / tildesubst
Text File  |  1998-10-30  |  5KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))                                      TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tcl_TildeSubst - replace tilde with home directory in a file name
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
  13.  
  14.      char *
  15.      TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt(_i_n_t_e_r_p, _n_a_m_e, _b_u_f_f_e_r_P_t_r)                                  |
  16.  
  17. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  18.      Tcl_Interp    *_i_n_t_e_r_p      (in)      Interpreter in which to report an
  19.                                           error, if any.
  20.  
  21.      char          *_n_a_m_e        (in)      File name, which may start with a
  22.                                           ``~''.
  23.  
  24.      Tcl_DString   *_b_u_f_f_e_r_P_t_r             If needed, this dynamic string is   |
  25.                                           used to store the new file name.  At|
  26.                                           the time of the call it should be   |
  27.                                           uninitialized or empty.  The caller |
  28.                                           must eventually call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee|
  29.                                           to free up anything stored here.
  30.  
  31.  
  32. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  33.      This utility procedure does tilde substitution.  If _n_a_m_e doesn't start
  34.      with a ``~'' character, then the procedure returns _n_a_m_e.  If _n_a_m_e does
  35.      start with a tilde, then TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt returns a new string identical to
  36.      _n_a_m_e except that the first element of _n_a_m_e is replaced with the location
  37.      of the home directory for the given user.  The substitution is carried
  38.      out in the same way that it would be done by _c_s_h.  If the tilde is
  39.      followed immediately by a slash, then the $$$$HHHHOOOOMMMMEEEE environment variable is
  40.      substituted.  Otherwise the characters between the tilde and the next
  41.      slash are taken as a user name, which is looked up in the password file;
  42.      the user's home directory is retrieved from the password file and
  43.      substituted.
  44.  
  45.      If TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt has to do tilde substitution then it uses the dynamic  |
  46.      string at *_b_u_f_f_e_r_P_t_r to hold the new string it generates.  After         |
  47.      TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt returns a non-NULL result, the caller must eventually     |
  48.      invoke TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee to free up any information placed in *_b_u_f_f_e_r_P_t_r.  |
  49.      The caller need not know whether or not TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt actually used the |
  50.      string;  TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt initializes *_b_u_f_f_e_r_P_t_r even if it doesn't use it,|
  51.      so the call to TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee will be safe in either case.
  52.  
  53.      If an error occurs (e.g. because there was no user by the given name)
  54.      then NULL is returned and an error message will be left at _i_n_t_e_r_p-
  55.      >_r_e_s_u_l_t.  When an error occurs, TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt frees the dynamic string  |
  56.      itself so that the caller need not call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))                                      TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))
  71.  
  72.  
  73.  
  74.      The caller is responsible for making sure that _i_n_t_e_r_p->_r_e_s_u_l_t has its
  75.      default empty value when TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt is invoked.
  76.  
  77.  
  78. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  79.      file name, home directory, tilde, user
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.